package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.AnswerDialogContract;
import com.magic.gre.mvp.model.AnswerDialogModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-02-21 19:26
 * 文件名: AnswerDialogPresenterImpl
 * 描述:
 */
public class AnswerDialogPresenterImpl extends BasePresenterImpl<AnswerDialogContract.View, AnswerDialogContract.Model>
        implements AnswerDialogContract.Presenter {
    public AnswerDialogPresenterImpl(AnswerDialogContract.View view) {
        super(view);
    }

    @Override
    public void pNewWordsSave(String vocabularyId) {
        mModel.mNewWordsSave(new CommonObserver<BaseObjectModel>(new TypeToken<BaseObjectModel>() {
        }.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel baseObjectModel) {
                mView.vNewWordsSave();
            }

            @Override
            public void onError(int status, String msg) {
                mView.doPrompt(msg);
            }
        }, vocabularyId);
    }

    @Override
    protected AnswerDialogContract.Model creatModel() {
        return new AnswerDialogModelImpl();
    }
}
